In [1]:
import pandas as pd
import numpy as np
import plotly.express as px
In [2]:
px
Out[2]:
<module 'plotly.express' from 'C:\\Users\\M.Rabby\\AppData\\Roaming\\Python\\Python310\\site-packages\\plotly\\express\\__init__.py'>
In [3]:
spotifyFeaturesData = pd.read_csv(r"C:\Users\M.Rabby\AppData\Roaming\Python\Python310\Scripts\data\SpotifyFeatures.csv")
In [4]:
spotifyFeaturesData
Out[4]:
genre artist_name track_name track_id popularity acousticness danceability duration_ms energy instrumentalness key liveness loudness mode speechiness tempo time_signature valence
0 Movie Henri Salvador C'est beau de faire un Show 0BRjO6ga9RKCKjfDqeFgWV 0 0.61100 0.389 99373 0.910 0.000000 C# 0.3460 -1.828 Major 0.0525 166.969 4/4 0.814
1 Movie Martin & les fées Perdu d'avance (par Gad Elmaleh) 0BjC1NfoEOOusryehmNudP 1 0.24600 0.590 137373 0.737 0.000000 F# 0.1510 -5.559 Minor 0.0868 174.003 4/4 0.816
2 Movie Joseph Williams Don't Let Me Be Lonely Tonight 0CoSDzoNIKCRs124s9uTVy 3 0.95200 0.663 170267 0.131 0.000000 C 0.1030 -13.879 Minor 0.0362 99.488 5/4 0.368
3 Movie Henri Salvador Dis-moi Monsieur Gordon Cooper 0Gc6TVm52BwZD07Ki6tIvf 0 0.70300 0.240 152427 0.326 0.000000 C# 0.0985 -12.178 Major 0.0395 171.758 4/4 0.227
4 Movie Fabien Nataf Ouverture 0IuslXpMROHdEPvSl1fTQK 4 0.95000 0.331 82625 0.225 0.123000 F 0.2020 -21.150 Major 0.0456 140.576 4/4 0.390
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
232720 Soul Slave Son Of Slide 2XGLdVl7lGeq8ksM6Al7jT 39 0.00384 0.687 326240 0.714 0.544000 D 0.0845 -10.626 Major 0.0316 115.542 4/4 0.962
232721 Soul Jr Thomas & The Volcanos Burning Fire 1qWZdkBl4UVPj9lK6HuuFM 38 0.03290 0.785 282447 0.683 0.000880 E 0.2370 -6.944 Minor 0.0337 113.830 4/4 0.969
232722 Soul Muddy Waters (I'm Your) Hoochie Coochie Man 2ziWXUmQLrXTiYjCg2fZ2t 47 0.90100 0.517 166960 0.419 0.000000 D 0.0945 -8.282 Major 0.1480 84.135 4/4 0.813
232723 Soul R.LUM.R With My Words 6EFsue2YbIG4Qkq8Zr9Rir 44 0.26200 0.745 222442 0.704 0.000000 A 0.3330 -7.137 Major 0.1460 100.031 4/4 0.489
232724 Soul Mint Condition You Don't Have To Hurt No More 34XO9RwPMKjbvRry54QzWn 35 0.09730 0.758 323027 0.470 0.000049 G# 0.0836 -6.708 Minor 0.0287 113.897 4/4 0.479

232725 rows × 18 columns

In [5]:
#find most 20 popular track name
popular_track = spotifyFeaturesData.sort_values('popularity', ascending=False).head(20)
popular_track
Out[5]:
genre artist_name track_name track_id popularity acousticness danceability duration_ms energy instrumentalness key liveness loudness mode speechiness tempo time_signature valence
9027 Dance Ariana Grande 7 rings 14msK75pk3pA33pzPVNtBF 100 0.5780 0.725 178640 0.321 0.000000 C# 0.0884 -10.744 Minor 0.3230 70.142 4/4 0.319
107804 Pop Ariana Grande 7 rings 14msK75pk3pA33pzPVNtBF 100 0.5780 0.725 178640 0.321 0.000000 C# 0.0884 -10.744 Minor 0.3230 70.142 4/4 0.319
86951 Rap Post Malone Wow. 6MWtB6iiXyIwun0YzU6DFP 99 0.1630 0.833 149520 0.539 0.000002 B 0.1010 -7.399 Minor 0.1780 99.947 4/4 0.385
107803 Pop Post Malone Wow. 6MWtB6iiXyIwun0YzU6DFP 99 0.1630 0.833 149520 0.539 0.000002 B 0.1010 -7.399 Minor 0.1780 99.947 4/4 0.385
107802 Pop Ariana Grande break up with your girlfriend, i'm bored 4kV4N9D1iKVxx1KLvtTpjS 99 0.0421 0.726 190440 0.554 0.000000 F 0.1060 -5.290 Minor 0.0917 169.999 4/4 0.335
9026 Dance Ariana Grande break up with your girlfriend, i'm bored 4kV4N9D1iKVxx1KLvtTpjS 99 0.0421 0.726 190440 0.554 0.000000 F 0.1060 -5.290 Minor 0.0917 169.999 4/4 0.335
66643 Hip-Hop Daddy Yankee Con Calma 5w9c2J52mkdntKOmRLeM2m 98 0.1100 0.737 193227 0.860 0.000002 G# 0.0574 -2.652 Minor 0.0593 93.989 4/4 0.656
107909 Pop Daddy Yankee Con Calma 5w9c2J52mkdntKOmRLeM2m 98 0.1100 0.737 193227 0.860 0.000002 G# 0.0574 -2.652 Minor 0.0593 93.989 4/4 0.656
138918 Reggaeton Daddy Yankee Con Calma 5w9c2J52mkdntKOmRLeM2m 98 0.1100 0.737 193227 0.860 0.000002 G# 0.0574 -2.652 Minor 0.0593 93.989 4/4 0.656
107829 Pop Ava Max Sweet but Psycho 25sgk305KZfyuqVBQIahim 97 0.0691 0.719 187436 0.704 0.000000 C# 0.1660 -4.724 Major 0.0476 133.002 4/4 0.628
86953 Rap Post Malone Sunflower - Spider-Man: Into the Spider-Verse 3KkXRkHbMCARz0aVfEt68P 97 0.5560 0.760 158040 0.479 0.000000 D 0.0703 -5.574 Major 0.0466 89.911 4/4 0.913
107875 Pop Pedro Capó Calma - Remix 5iwz1NiezX7WWjnCgY5TH4 97 0.3230 0.826 238200 0.773 0.000000 B 0.1430 -4.218 Minor 0.0524 126.899 4/4 0.761
92824 Indie Halsey Without Me 5p7ujcrUXASCNwRaWNHR1C 97 0.2970 0.752 201661 0.488 0.000009 F# 0.0936 -7.050 Major 0.0705 136.041 4/4 0.533
107812 Pop Marshmello Happier 2dpaYNEQHiRxtZbfNsse99 97 0.1910 0.687 214290 0.792 0.000000 F 0.1670 -2.749 Major 0.0452 100.015 4/4 0.671
9028 Dance Halsey Without Me 5p7ujcrUXASCNwRaWNHR1C 97 0.2970 0.752 201661 0.488 0.000009 F# 0.0936 -7.050 Major 0.0705 136.041 4/4 0.533
9037 Dance Ava Max Sweet but Psycho 25sgk305KZfyuqVBQIahim 97 0.0691 0.719 187436 0.704 0.000000 C# 0.1660 -4.724 Major 0.0476 133.002 4/4 0.628
107806 Pop Post Malone Sunflower - Spider-Man: Into the Spider-Verse 3KkXRkHbMCARz0aVfEt68P 97 0.5560 0.760 158040 0.479 0.000000 D 0.0703 -5.574 Major 0.0466 89.911 4/4 0.913
107810 Pop Sam Smith Dancing With A Stranger (with Normani) 6Qs4SXO9dwPj5GKvVOv8Ki 97 0.4500 0.741 171030 0.520 0.000002 G# 0.2220 -7.513 Major 0.0656 102.998 4/4 0.347
107808 Pop Halsey Without Me 5p7ujcrUXASCNwRaWNHR1C 97 0.2970 0.752 201661 0.488 0.000009 F# 0.0936 -7.050 Major 0.0705 136.041 4/4 0.533
107851 Pop DJ Snake Taki Taki (with Selena Gomez, Ozuna & Cardi B) 4w8niZpiMy6qz1mntFA5uM 96 0.1530 0.841 212500 0.798 0.000003 C# 0.0618 -4.206 Minor 0.2290 95.948 4/4 0.591
In [6]:
#showing top 20 popular songs in scatter chart
figTwo = px.scatter(popular_track,x='artist_name', y='track_name',color='popularity')
figTwo.show()
In [8]:
# showing top 30 popular songs in bar chart
fig = px.bar(spotifyFeaturesData.sort_values('genre',ascending=False).head(30), x='artist_name', y='popularity')
fig.show()
In [ ]: